package com.slunk.platforms;

import java.util.Map;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;

public class SSwitchableActingObject extends SActingObject {
	boolean isOn;
	static int ON = 1;
	static int OFF = 0;
	
	public SSwitchableActingObject(TextureAtlas parentTextureAtlas, Map<SOPCodes, String> offState, Map<SOPCodes, String> onState, boolean defaultState) {
		super(parentTextureAtlas, offState);
		isOn = defaultState;
		this.addState(onState);
		
		if (isOn) {
			this.activateStateAt(ON);
		} else {
			this.activateStateAt(OFF);
		}
	}
	
	public void switchOn() {
		isOn = true;
		this.activateStateAt(ON);
	}
	
	public void switchOff() {
		isOn = false;
		this.activateStateAt(OFF);
	}
	
	public void flipSwitch() {
		if (isOn) {
			isOn = false;
			this.activateStateAt(OFF);
		} else if (!isOn) {
			isOn = true;
			this.activateStateAt(ON);
		}
	}
	
	public void flipTo(boolean state) {
		isOn = state;
		if (isOn) {
			this.activateStateAt(ON);
		} else if (!isOn) {
			this.activateStateAt(OFF);
		}
	}
}
